package com.huangmb.anymark.server.service.impl;

import com.huangmb.anymark.server.dao.BaseDao;
import com.huangmb.anymark.server.dao.CloudMapDao;
import com.huangmb.anymark.server.model.CloudMap;
import com.huangmb.anymark.server.service.CloudMapService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author hmb
 * @version 1.0
 * @since 2016/5/22 11:31
 */
@Service(value = "cloudMapService")
@Transactional
public class CloudMapServiceImpl extends BaseServiceImpl<CloudMap> implements CloudMapService {
    @Resource(name = "cloudMapDao")
    private CloudMapDao mCloudMapDao;
    @Resource(name = "cloudMapDao")
    @Override
    public void setDao(BaseDao<CloudMap> dao) {
        super.setDao(dao);
    }

    @Override
    public CloudMap findByMarkerId(Integer id) {
        String hql = "from CloudMap where marker.id = "+id;
        List<CloudMap> list = mCloudMapDao.findByHQL(hql);
        if(list != null && !list.isEmpty()){
            return list.get(0);
        }
        return null;
    }
}
